package com.zhx.threadcoreknowledge.background;

/**
 * @author ：zhanghaixuan
 * @date ：Created in 2019-10-05 10:18
 * 用途         ： 展示初始化未完毕,就this赋值
 */
public class MultiThreadsError4 {

    static Point point;

    public static void main(String[] args) throws InterruptedException {
        new PointMaker().start();

        Thread.sleep(105);

        if(point != null){
            System.out.println(point);
        }
    }
}

class Point{
    private final int x,y;

    public Point(int x, int y) throws InterruptedException {
        this.x = x;
        MultiThreadsError4.point = this;

        Thread.sleep(100);
        this.y = y;
    }

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}

class PointMaker extends Thread{
    @Override
    public void run() {
        try {
            Point point = new Point(1, 1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
